/*******************************************************************************

This code file produces Table A5, "Impacts of Developer Specialization on 421-a Participation and Lot Ownership."

*******************************************************************************/

*** Manage settings

	run "$dir/code/modules/settings.do"
	
*** Load Stata-TeX

	do "$code/modules/stata-tex.do"
	cd "$tables/estimates"
	
*** Load data

	use "$data/clean/cleaned_data.dta", clear
	
********************************************************************************
* Complete table analysis
********************************************************************************

*** Logit, No FE

	logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo, cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax0) format(%5.2f) all
	store_est_tpl using tableA5.csv, coef(sh_incl_dev_lo) name(shincl0) format(%5.2f) all
		
	quietly logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo, cl(nta)
	nlcom (cost_adv0: _b[sh_incl_dev_lo]/_b[dtaxrate_onsite]), post
	store_est_tpl using tableA5.csv, coef(cost_adv0) name(cost_adv0) all
	
	reg sh_incl_dev_lo dtaxrate_onsite, cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax0_1) format(%5.3f) all
	
*** Logit, borough FEs, expanding controls

	* No controls
		
	logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo i.borough i.yearpermit, cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax1) format(%5.2f) all
	store_est_tpl using tableA5.csv, coef(sh_incl_dev_lo) name(shincl1) format(%5.2f) all
		
	quietly logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo i.borough i.yearpermit, cl(nta)
	nlcom (cost_adv1: _b[sh_incl_dev_lo]/_b[dtaxrate_onsite]), post
	store_est_tpl using tableA5.csv, coef(cost_adv1) name(cost_adv1) all
	
	reghdfe sh_incl_dev_lo dtaxrate_onsite, a(borough yearpermit) cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax1_1) format(%5.3f) all
	
	* Lot controls
	
	logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo $controls_lot i.borough i.yearpermit, cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax2) format(%5.2f) all
	store_est_tpl using tableA5.csv, coef(sh_incl_dev_lo) name(shincl2) format(%5.2f) all
		
	quietly logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo $controls_lot i.borough i.yearpermit, cl(nta)
	nlcom (cost_adv2: _b[sh_incl_dev_lo]/_b[dtaxrate_onsite]), post
	store_est_tpl using tableA5.csv, coef(cost_adv2) name(cost_adv2) all
	
	reghdfe sh_incl_dev_lo dtaxrate_onsite $controls_lot, a(borough yearpermit) cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax2_1) format(%5.3f) all
	
	* Lot + neighborhood controls
	
	logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo $controls_lot $controls_block i.borough i.yearpermit, cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax3) format(%5.2f) all
	store_est_tpl using tableA5.csv, coef(sh_incl_dev_lo) name(shincl3) format(%5.2f) all
		
	quietly logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo $controls_lot $controls_block i.borough i.yearpermit, cl(nta)
	nlcom (cost_adv3: _b[sh_incl_dev_lo]/_b[dtaxrate_onsite]), post
	store_est_tpl using tableA5.csv, coef(cost_adv3) name(cost_adv3) all
	
	reghdfe sh_incl_dev_lo dtaxrate_onsite $controls_lot $controls_block, a(borough yearpermit) cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax3_1) format(%5.3f) all
	
*** Logit, NTA FEs, expanding controls

	* No controls
		
	logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo i.nta i.yearpermit, cl(nta) 
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax4) format(%5.2f) all
	store_est_tpl using tableA5.csv, coef(sh_incl_dev_lo) name(shincl4) format(%5.2f) all
		
	quietly logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo i.nta i.yearpermit, cl(nta)
	nlcom (cost_adv4: _b[sh_incl_dev_lo]/_b[dtaxrate_onsite]), post
	store_est_tpl using tableA5.csv, coef(cost_adv4) name(cost_adv4) all
	
	reghdfe sh_incl_dev_lo dtaxrate_onsite, a(nta yearpermit) cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax4_1) format(%5.3f) all
	
	* Lot controls
	
	logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo $controls_lot i.nta i.yearpermit, cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax5) format(%5.2f) all
	store_est_tpl using tableA5.csv, coef(sh_incl_dev_lo) name(shincl5) format(%5.2f) all
		
	quietly logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo $controls_lot i.nta i.yearpermit, cl(nta)
	nlcom (cost_adv5: _b[sh_incl_dev_lo]/_b[dtaxrate_onsite]), post
	store_est_tpl using tableA5.csv, coef(cost_adv5) name(cost_adv5) all
	
	reghdfe sh_incl_dev_lo dtaxrate_onsite $controls_lot, a(nta yearpermit) cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax5_1) format(%5.3f) all
	
	* Lot + neighborhood controls
	
	logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo $controls_lot $controls_block i.nta i.yearpermit, cl(nta) difficult
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax6) format(%5.2f) all
	store_est_tpl using tableA5.csv, coef(sh_incl_dev_lo) name(shincl6) format(%5.2f) all
		
	quietly logit inclusionary_onsite dtaxrate_onsite sh_incl_dev_lo $controls_lot $controls_block i.nta i.yearpermit, cl(nta) difficult
	nlcom (cost_adv6: _b[sh_incl_dev_lo]/_b[dtaxrate_onsite]), post
	store_est_tpl using tableA5.csv, coef(cost_adv6) name(cost_adv6) all
	
	reghdfe sh_incl_dev_lo dtaxrate_onsite $controls_lot $controls_block, a(nta yearpermit) cl(nta)
	store_est_tpl using tableA5.csv, coef(dtaxrate_onsite) name(dtax6_1) format(%5.3f) all

	
********************************************************************************
* Create table
********************************************************************************
	
	cat tableA5.csv

	cap erase "$tables/tableA5.tex"

	cd "$code/modules"
	
	capture table_from_tpl, t("$tables/templates/tableA5.tex") ///
						r("$tables/estimates/tableA5.csv") ///
						o("$tables/output/tableA5.tex") 
						
	capture table_from_tpl, t("$tables/templates/tableA5.tex") ///
						r("$tables/estimates/tableA5.csv") ///
						o("$tables_overleaf/tableA5.tex") 
	
	
